package com.kalvan.mq;

import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * 判断是否启用MqProducer
 *
 * @author chenliang
 */
public class MqCondition implements Condition {

    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        String mqProperty = context.getEnvironment().getProperty("rocketmq.namesrvAddr");
        return StringUtils.isNotBlank(mqProperty);
    }
}
